#include "stdafx.h"
#include "HBLoadItemDBOpt.h"
#include <QSqlQuery>
#include <QVariant>


QSqlDatabase* CHBDbItemOpt::GetDB()
{
	static QSqlDatabase db = QSqlDatabase::addDatabase(hbDBType);   
	if (db.isOpen())
	{
		return &db;
	}

	db.setDatabaseName(hbDBName);   
	if ( !db.open() )   
	{
		g_pushDetail(HE_OpenDBError);
		return NULL;
	}

	CHBDownLoadItem item;
	item.CreateTable(&db, ItemTableName);

	g_pushDetail(HE_InitCurlSuccess);
	return &db;
}

QString CHBDbItemOpt::GetTableName()
{
	return ItemTableName;
}
